//https://www.nowcoder.com/practice/ee5de2e7c45a46a090c1ced2fdc62355?tpId=85&&tqId=29867&rp=1&ru=/activity/oj&qru=/ta/2017test/question-ranking

//将一句话的单词进行倒置，标点不倒置。比如 I like beijing. 经过函数后变为：beijing. like I

#include <stdio.h>

void reverase(char* head, char* end)
{
	char tmp = 0;
	while (head < end)
	{
		tmp = *head;
		*head = *end;
		*end = tmp;
		head++;
		end--;
	}
}

int main()
{
	char arr[100] = { 0 };
	gets(arr);
	int len = strlen(arr);
	//逆序整个串
	reverase(arr, arr + len - 1);
	//逆序每个字母
	char* cur = arr;
	char* start = arr;
	while (*cur)
	{
		while (*cur != ' ' && *cur != '\0')
		{
			cur++;
		}
		reverase(start, cur - 1);
		if (*(cur) == ' ')
		{
            cur++;
			start = cur;
		}
	}
	printf("%s", arr);
	return 0;
}